﻿<Page
    x:Class="BlueFlyPhone.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:BlueFlyPhone.Converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    
    <Page.Resources>
        
       
        <local:ConnectionStateConvertor x:Key="connStateConvertor"/>
        

    </Page.Resources>
    
    
    <Grid>
       <StackPanel Margin="30,0,0,0">

           <Button Content="Settings" HorizontalAlignment="Left" Height="50" Margin="0,0,0,0" VerticalAlignment="Top" Width="115" Click="btnNavigateBlueToothSettings_Click"/>

            <Button x:Name="btnConnect" Content="{Binding ConnectionState, Mode=OneWay, Converter={StaticResource connStateConvertor},FallbackValue=Connect}" HorizontalAlignment="Left" Height="50" Margin="0,6,0,0" VerticalAlignment="Top" Width="115" Click="Button_Click"/>

            <TextBlock HorizontalAlignment="Left" FontSize="20"
                    TextWrapping="Wrap" Text="{Binding ConnectionState,FallbackValue=State}" />

            <StackPanel Margin="0,0,0,0" Orientation="Horizontal">

                <Button Content="Set Alt" Margin="0,0,0,0" HorizontalAlignment="Left" Height="50"  VerticalAlignment="Top" Width="93" Click="btnSetAltitude_Click"/>

                <TextBox x:Name="txtAlt" Margin="5,0,0,0" AcceptsReturn="False" VerticalAlignment="Center" MaxLength="5" Width="100" InputScope="Number" ></TextBox>

                <TextBlock Margin="4,0,0,0" HorizontalAlignment="Left" FontSize="30"
                    TextWrapping="NoWrap" Text="{Binding AltitudeDisplayUnit,FallbackValue=:m}" 
                   VerticalAlignment="Center" Height="32" />
            </StackPanel>

            <StackPanel Margin="0,6,0,0" Orientation="Horizontal">

                <Button Content="&lt;"  Margin="0,0,4,0"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="Button_DecreaseQNH_Click" />
                <TextBox x:Name="txtqnh" Margin="0,0,0,0"  VerticalAlignment="Center" AcceptsReturn="False" MaxLength="4" Width="100" InputScope="Number" ></TextBox>
                <Button Content="&gt;" Margin="4,0,0,0" Width="10" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="Button_IncreaseQNH_Click"/>

            </StackPanel>
           <Button Content="Set QNH" Margin="0,0,0,0"  HorizontalAlignment="Left" Height="50"  VerticalAlignment="Top" Width="93" Click="btnSetQNH_Click"/>




            <Border  BorderBrush="Blue" CornerRadius="3" BorderThickness="2">
           <StackPanel Visibility="Collapsed" HorizontalAlignment="Left" Orientation="Horizontal">

                <TextBlock HorizontalAlignment="Left" FontSize="30" TextAlignment="Right"
                   TextWrapping="Wrap" Text="{Binding Pressure,FallbackValue=Pressure}" 
                   VerticalAlignment="Center" Height="32" Width="130"/>

                <TextBlock Margin="4,0,0,0" HorizontalAlignment="Left" FontSize="30"
                           
                    TextWrapping="NoWrap" Text="{Binding PressureDisplayUnit,FallbackValue=:hPa}" 
                   VerticalAlignment="Center" Height="32" />

            </StackPanel>
            
            </Border>

            <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
           
               <TextBlock HorizontalAlignment="Left" FontSize="30"
                    TextWrapping="Wrap" Text="{Binding Altitude,FallbackValue=Altitude}" 
                   TextAlignment="Right" Margin="0"
                   VerticalAlignment="Center" Height="32" Width="130"/>

            <TextBlock Margin="4,0,0,0" HorizontalAlignment="Left" FontSize="30"
                    TextWrapping="NoWrap" Text="{Binding AltitudeDisplayUnit,FallbackValue=:m}" 
                   VerticalAlignment="Center" Height="32" />
            </StackPanel>


            <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">

                <TextBlock Margin="0"  HorizontalAlignment="Left" FontSize="30"
                           TextAlignment="Right"
                    TextWrapping="Wrap" Text="{Binding Climbrate,FallbackValue=Climbrate}" 
                   VerticalAlignment="Center" Height="32" Width="130"/>

                <TextBlock Margin="4,0,0,0" HorizontalAlignment="Left" FontSize="30"
                    TextWrapping="NoWrap" Text="{Binding VarioDisplayUnit,FallbackValue=:m/s}" 
                   VerticalAlignment="Center" Height="32" />

            </StackPanel>

            <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">

                <TextBlock Margin="0"  HorizontalAlignment="Left" FontSize="30"
                           TextAlignment="Right"
                    TextWrapping="Wrap" Text="{Binding BatteryCharge,FallbackValue=100}" 
                   VerticalAlignment="Center" Height="32" Width="130"/>

                <TextBlock Margin="4,0,0,0" HorizontalAlignment="Left" FontSize="30"
                    TextWrapping="NoWrap" Text="{Binding BatteryDisplayUnit,FallbackValue=:% Charge}" 
                   VerticalAlignment="Center" Height="32" />
                </StackPanel>



            <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">

                <TextBlock Margin="0"  HorizontalAlignment="Left" FontSize="30"
                           TextAlignment="Right"
                    TextWrapping="Wrap" Text="{Binding Latitude,FallbackValue=Latitude}" 
                   VerticalAlignment="Center" Height="32" Width="130"/>

                <TextBlock Margin="4,0,0,0" HorizontalAlignment="Left" FontSize="28"
                    TextWrapping="NoWrap" Text="{Binding LatLngDisplayUnit,FallbackValue=:deg}" 
                   VerticalAlignment="Center" Height="32" />

            </StackPanel>
            <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">

                <TextBlock Margin="0"  HorizontalAlignment="Left" FontSize="30"
                           TextAlignment="Right"
                    TextWrapping="Wrap" Text="{Binding Longitude,FallbackValue=Longitude}" 
                   VerticalAlignment="Center" Height="32" Width="130"/>

                <TextBlock Margin="4,0,0,0" HorizontalAlignment="Left" FontSize="28"
                    TextWrapping="NoWrap" Text="{Binding LatLngDisplayUnit,FallbackValue=:deg}" 
                   VerticalAlignment="Center" Height="32" />

            </StackPanel>

            <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">

                <TextBlock Margin="0"  HorizontalAlignment="Left" FontSize="30"
                           TextAlignment="Right"
                    TextWrapping="Wrap" Text="{Binding GPSAltitude,FallbackValue=GPS Alt}" 
                   VerticalAlignment="Center" Height="32" Width="130"/>

                <TextBlock Margin="4,0,0,0" HorizontalAlignment="Left" FontSize="30"
                    TextWrapping="NoWrap" Text="{Binding AltitudeDisplayUnit,FallbackValue=:m}" 
                   VerticalAlignment="Center" Height="32" />

                <TextBlock Margin="4,0,0,0" HorizontalAlignment="Left" FontSize="20"
                    TextWrapping="NoWrap" Text="+-" 
                   VerticalAlignment="Center" Height="20" />

                <TextBlock Margin="4,0,0,0" HorizontalAlignment="Left" FontSize="20"
                            
                    TextWrapping="NoWrap" Text="{Binding GPSAltitudeAccuracy,FallbackValue=m}" 
                   VerticalAlignment="Center" Height="20" />


            </StackPanel>

            <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">

                <TextBlock Margin="0"  HorizontalAlignment="Left" FontSize="30"
                           TextAlignment="Right"
                    TextWrapping="Wrap" Text="{Binding Velocity,FallbackValue=Velocity}" 
                   VerticalAlignment="Center" Height="32" Width="130"/>

                <TextBlock Margin="4,0,0,0" HorizontalAlignment="Left" FontSize="30"
                    TextWrapping="NoWrap" Text="{Binding VarioDisplayUnit,FallbackValue=:m/s}" 
                   VerticalAlignment="Center" Height="32" />

            </StackPanel>

            <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">

                <TextBlock Margin="0"   HorizontalAlignment="Left" FontSize="30"
                           TextAlignment="Right"
                    TextWrapping="Wrap" Text="{Binding Heading,FallbackValue=deg}" 
                   VerticalAlignment="Center" Height="32" Width="130"/>    
                
                <TextBlock  Margin="4,0,0,0" HorizontalAlignment="Left" FontSize="28"
                    TextWrapping="NoWrap" Text="{Binding LatLngDisplayUnit,FallbackValue=:deg}" 
                   VerticalAlignment="Center" Height="32" /> 

            </StackPanel>


            <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">

                <TextBlock Margin="0" HorizontalAlignment="Left" TextAlignment="Right" FontSize="30"
                    TextWrapping="NoWrap" Text="Source" 
                   VerticalAlignment="Top" Height="32" Width="130"/>
                
                
                <TextBlock Margin="4,0,0,0"   HorizontalAlignment="Left" FontSize="28"
                           TextAlignment="Left"
                    TextWrapping="Wrap" Text="{Binding PositionSource,FallbackValue=:Unknown}" 
                   VerticalAlignment="Center" Height="32" />


            </StackPanel>

            <ListView  Margin="2" ItemsSource="{Binding Errors}" HorizontalAlignment="Left" >
                <ListView.ItemTemplate>
                    
                    <DataTemplate>
                        <Border HorizontalAlignment="Stretch" BorderBrush="Red" BorderThickness="1">
                        <TextBlock TextWrapping="WrapWholeWords" FontSize="16" Text="{Binding}"></TextBlock>
                        </Border>
     
                    </DataTemplate>
   
                </ListView.ItemTemplate>

            </ListView>

        </StackPanel>
    </Grid>
</Page>
